<%@ page pageEncoding="UTF-8"%>
<%@ include file="../../resources/commonUI.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="${ctx}/static/akt-ui/plugins/layui/css/layui.css" media="all" />
    <script type="text/javascript" src="${ctx}/static/akt-ui/plugins/layui/layui.js"></script>
    <script type="text/javascript" src="${ctx}/static/jquery/jquery-1.8.3.min.js"></script>
</head>
<body>
<div>
    <form class="layui-form " method="post" style="padding: 20px;">
        <div class="layui-form-item">
            <label class="layui-form-label">部门：</label>
            <div class="layui-input-block">
                <input type="text" name="deptName" id="deptName" value="${user.deptName}" placeholder="部门" class="layui-input" />
            </div>
        </div>
        <input type="hidden" name="telphone" id="telphone" value="${user.telphone}" placeholder="分机号" class="layui-input" />
        <div class="layui-form-item">
            <label class="layui-form-label">姓名：</label>
            <div class="layui-input-block">
                <input type="text" name="displayName" id="displayName" value="${user.displayName}" placeholder="请输入主叫人姓名" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱：</label>
            <div class="layui-input-block">
                <input type="text" name="email" id="email" value="${user.email}"  class="layui-input" onblur="findUserByEmail()"/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">分机号：</label>
            <div class="layui-input-block">
                <input type="text" name="extension" id="extension" value="${user.extension}" placeholder="分机号" class="layui-input" />
            </div>
        </div>
    </form>
</div>

</body>
<script type="text/javascript">
    function findUserByEmail() {
        $.ajax({
            type: "POST",
            url: "/user/user",
            data: {
                email: $("#email").val()
            },
            dataType: "json",
            success: function(result){
                if(result.code=='0'){
                    var users = result.data;
                    users.forEach(user =>{
                        $("#telphone").val(user.telphone);
                        $("#displayName").val(user.displayName);
                        $("#email").val(user.email);
                        $("#extension").val(user.extension);
                        $("#deptName").val(user.deptName);
                    });
                }
            }
        });





    }

</script>

</html>
